#include "swpsimendpointgraphicitem.h"

#include "graphicitemcommon.h"

using namespace core;
using namespace swp;

SwpSimEndPointGraphicItem::SwpSimEndPointGraphicItem(QGraphicsItem* parent) :
    SwpEndPointGraphicItem(parent), ISimItem(),
    m_isInSimPath(false),
    m_originId()
{
    setFlag(QGraphicsItem::ItemIsMovable, false);
}

SwpSimEndPointGraphicItem::SwpSimEndPointGraphicItem(
    SwpEndPointGraphicItem* from,
        QGraphicsItem* parent) : SwpEndPointGraphicItem(parent), ISimItem(),
        m_isInSimPath(false),
        m_originId(from->id())
{
    setFlag(QGraphicsItem::ItemIsMovable, false);

    setPos(from->pos());
}

SwpSimEndPointGraphicItem::~SwpSimEndPointGraphicItem()
{

}

bool SwpSimEndPointGraphicItem::supportsConnection(
        const ConnectionData& connection) const
{
    return connection.ConnectionId == CONNECTION_SIM_PATH;
}

int SwpSimEndPointGraphicItem::type() const
{
    return SWP_SIM_END_POINT_ITEM;
}

IEditorItem* SwpSimEndPointGraphicItem::copy() const
{
    return new SwpSimEndPointGraphicItem();
}

bool SwpSimEndPointGraphicItem::isInSimPath() const
{
    return m_isInSimPath;
}

void SwpSimEndPointGraphicItem::setInSimPath(bool in)
{
    if (in)
    {
        setPen(QPen(m_palette->acceptsConnectionColor(), 2));
    }
    else
    {
        setPen(QPen(m_palette->borderColor(), 1));
    }

    m_isInSimPath = in;
}

QUuid SwpSimEndPointGraphicItem::originId() const
{
    return m_originId;
}
